package com.itheima.api;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.itheima.mapper.PmsProductLadderMapper;
import com.itheima.pojo.db.PmsProductLadder;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@DubboService
public class PmsProductLadderApiImpl implements PmsProductLadderApi {
    @Autowired
    private PmsProductLadderMapper pmsProductLadderMapper;

    @Override
    public void insertList(List<PmsProductLadder> list, Long productId) {
        for (PmsProductLadder pmsProductLadder : list) {
            pmsProductLadder.setId(null);
            pmsProductLadder.setProductId(productId);
            pmsProductLadderMapper.insert(pmsProductLadder);
        }
    }

    @Override
    public void deleteById(Long id) {
        pmsProductLadderMapper.delete(new LambdaQueryWrapper<PmsProductLadder>().eq(PmsProductLadder::getProductId, id));
    }

    @Override
    public List<PmsProductLadder> selectByPid(Long id) {
        return pmsProductLadderMapper.selectList(new LambdaQueryWrapper<PmsProductLadder>().eq(PmsProductLadder::getProductId, id));
    }
}
